package thread.thread015;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @program: baseModule
 * @description:
 * @author: zhanghz001
 * @create: 2020-10-26 02:43
 **/
public class Cooker implements Runnable {
    private final ArrayBlockingQueue<String> queue;

    public Cooker(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                queue.put("包子");
                System.out.println(Thread.currentThread().getName() + " 生成包子 :, 剩余 " + queue.size());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }
}
